package com.yinNuo.collectWool.mobileApi.collectWoolApi;

import com.yinNuo.collectWool.core.Response;
import com.yinNuo.collectWool.mobileApi.entity.WoolTaskDetail;
import com.yinNuo.collectWool.mobileApi.service.WoolTaskDetailService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 单个羊毛(WoolTaskDetail)表控制层
 *
 * @author makejava
 * @since 2021-12-12 11:12:08
 */
@RestController
@RequestMapping("/woolTaskDetail")
public class WoolTaskDetailApi {
    /**
     * 服务对象
     */
    @Resource
    private WoolTaskDetailService woolTaskDetailService;

    /**
     * 查询所有app详细任务
     * @return 所有app详细任务数据
     */
    @GetMapping("/getAllAppDetails")
    public Response getAllAppDetails() {
        return Response.ok(this.woolTaskDetailService.list());
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<WoolTaskDetail> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.woolTaskDetailService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param woolTaskDetail 实体
     * @return 新增结果
     */
    @PostMapping("/add")
    public ResponseEntity<WoolTaskDetail> add(WoolTaskDetail woolTaskDetail) {
        return ResponseEntity.ok(this.woolTaskDetailService.insert(woolTaskDetail));
    }

    /**
     * 编辑数据
     *
     * @param woolTaskDetail 实体
     * @return 编辑结果
     */
    @PutMapping("/edit")
    public ResponseEntity<WoolTaskDetail> edit(WoolTaskDetail woolTaskDetail) {
        return ResponseEntity.ok(this.woolTaskDetailService.update(woolTaskDetail));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping("/deleteById")
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.woolTaskDetailService.deleteById(id));
    }

}

